﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[proc_AB_Interface_GetItem]
(
	@id INT
)
AS
DECLARE @Product VARCHAR(200)
DECLARE @SupplierId VARCHAR(20)
BEGIN
		SELECT @Product=ProductId FROM AB_Interface WHERE id=@id
	--SELECT * FROM AB_Interface WHERE id=@id
	SET @Product=REPLACE(@Product,'{','')
	SET @Product=REPLACE(@Product,'}',',')
	SET @Product=SUBSTRING(@Product,1,LEN(@Product)-1)
	--SELECT @Product
	--SET @str='SELECT Title FROM Product WHERE id IN ('+@Product+')'
	--EXEC(@str)
	
	--供应商
	IF(charindex(',',@Product)>0)
	BEGIN
	 SELECT @SupplierId=SupplierId FROM Product WHERE id=SUBSTRING(@Product,0,charindex(',',@Product))
	END
	ELSE
		BEGIN
			 SELECT @SupplierId=SupplierId FROM Product WHERE id=@Product
		END
	--SELECT @Product

	SELECT * 
	,(select @SupplierId) AS SupplierId
	FROM AB_Interface WHERE id=@id

	SET NOCOUNT ON;
END